/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package TMS;
import java.util.ArrayList;
/**
 *
 * @author Zachary
 */
public class User_Profile {
    private String user_name;
    private int user_pin;
    private ArrayList<workout_session> session_list;
    private boolean logged_in;
    //Constructor
    public User_Profile(){
        user_name = "Guest";
        user_pin = 0;
        session_list = new ArrayList<workout_session>();
        logged_in = false;
    }
    //Profile management
    public void set_user_name(String value){
        user_name = value;
    }
    public String get_user_name(){
        return user_name;
    }
    public void set_user_pin(int value){
        user_pin = value;
    }
    public int get_user_pin(){
        return user_pin;
    }
    public void set_logged_in(boolean value){
        logged_in = value;
    }
    public boolean get_logged_in (){
        return logged_in;
    }
    //Session Management
    public workout_session new_session(){
        workout_session ns = new workout_session();
        session_list.add(ns);
        return ns;
    }
    public workout_session get_session(int number){
        if (number >= 0 && number < session_list.size()){
            return session_list.get(number);
        }
        else return null;
    }
    public int get_session_count(){
        return session_list.size();
    }
    //toString
    @Override
    public String toString(){
        String temp = "User: " + user_name + "\nHistory:\n";
        for (int i = 0; i < get_session_count(); i++){
            workout_session iSession = session_list.get(i);
            java.text.NumberFormat fmt = java.text.NumberFormat.getNumberInstance();
            fmt.setMinimumFractionDigits(5);fmt.setMaximumFractionDigits(5);
            temp += "\nSession " + (i + 1);
            temp += "\n\t Time: " + fmt.format(iSession.session_time / 60) + " Minutes";
            temp += "\n\t Average Heartrate: " + fmt.format(iSession.heartrate_average) + " BPM";
            temp += "\n\t Peak Heartrate: " + fmt.format(iSession.heartrate_peak) + " BPM";
            temp += "\n\t Calories Burned: " + fmt.format(iSession.calories_burned) + " Calories";
            temp += "\n\t Distance (Total): " + fmt.format(iSession.distance_run) + " Miles";
            temp += "\n\t Distance (Climbed): " + fmt.format(iSession.distance_climbed) + " Miles";

        }
        return temp;
    }
}